var sys_use = null;
var timer = 5000;
var os = require('os');
function get_cpu(){
    if(sys_use == null){
        sys_use = getProcessInfo();
        setTimeout(get_cpu,timer);
        return;
    }
    var user = process.cpuUsage(sys_use.cpu).user;
    sys_use = getProcessInfo();
    var obj = {};
    obj.cpu = (user/timer/1000).toFixed(4)*100;
    var mem_per = sys_use.mem.rss;
    var mem_total = sys_use.totalmem;
    obj.mem = (mem_per/1024/1024).toFixed(2)+"MB";
    obj.mem_scale = (mem_per/mem_total).toFixed(4)*100;
    // setTimeout(get_cpu,timer);
    return obj;
}
exports.get_cpu = get_cpu;